package com.hs.android.fortress.net;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.protocol.HTTP;

public class FormPostCommand extends PostMethodCommand{
	
	private String mUrl;
	private List<NameValuePair> mParams;
	
	public FormPostCommand(String path, List<NameValuePair> params) {
		mUrl = BASIC_URL + path;
		mParams = params;
	}
	
	@Override
	protected HttpPost makeHttpPost() throws IOException {
		
		HttpPost post = new HttpPost(mUrl);
		
		if(mParams != null){
			post.setHeader("Content-Type", AsyncNetworking.MIME_FORM);
			post.setEntity(new UrlEncodedFormEntity(mParams));
		}
		
		return post;
	}

	public void setParams(Object params) {
		mParams = (List<NameValuePair>)params;
	}

}
